#ifndef _BBSINGLETON_H_
#define _BBSINGLETON_H_

template <typename T>
class BBSingleton
{
private:
	BBSingleton(const BBSingleton<T>&){};
	BBSingleton& operator=(const BBSingleton<T>&){};

protected:
	virtual ~BBSingleton(){_mInstance = 0;}
	BBSingleton(){};
	static T* _mInstance;
public:
	static void Release() { if (_mInstance) delete _mInstance;}
	static T* getInstance()
	{
		if(_mInstance == 0)
			_mInstance = new T();
		return _mInstance;
	}
};

template <typename T> 
T* BBSingleton<T>::_mInstance = 0;

#endif